<?php
include("common.inc.php");
InitGP(array("action","gid","page")); //初始化變量全局返回

//初始化團購對象
include(INC_PATH."/group.class.php");
$gp=new GroupClass();

if($action=="" || empty($action)){
	//當設置了地區時候
	if (!empty($_cityid)) {
		$cwherestr[]="cityid=".$_cityid;		
		$gwherestr[]="G.cityid=".$_cityid;
	}
//	$todaystart=strtotime(date('Y-m-d 0:0:0',time()));
	$todaystart=time();
	
	$cwherestr[]="state=1";
	//$cwherestr[]="group_begin_time <{$todaystart}";
	$cwherestr[]="group_end_time < {$todaystart}";
	$cwherestr[]="group_buynum > 0";
	$gwherestr[]="G.state=1";
	//$gwherestr[]="G.group_begin_time <{$todaystart}";
	$gwherestr[]="G.group_end_time < {$todaystart}";
	$gwherestr[]="G.group_buynum > 0";
	
	if(!empty($cwherestr)) $cwheresql = implode(' AND ', $cwherestr);	//條件匯總
	if(!empty($gwherestr)) $gwheresql = implode(' AND ', $gwherestr);	//條件匯總
	
	//獲取當前頁碼
	$total=$gp->getcount($cwheresql); 							  //總信息數
	$pagesize=10;												  //一頁顯示信息數
	
	if(!empty($cfg_site_pagenum))$pagesize=$cfg_site_pagenum;
	$page = isset($page) ? max(1, intval($page)) : 1;             //處理頁碼變量
	$offset=($page-1)*$pagesize;   								  //偏移量
	$dataarray=$gp->getdata("$offset,$pagesize","IMG",$gwheresql,"","G.*,A.filepath,A.thumb"); //獲取團購數據
	
	include(INC_PATH."/article.class.php");
	$art=new ArticleClass();
	
	$datagg=$art->getdata('','typeid=3');
	
	//包含後台模板文件
	include template('grouplist');//包含輸出指定模板
}

?>